package com.ewanghuiju.app.ui.shopmail.activity;

import android.view.View;
import android.widget.ImageView;
import android.widget.RelativeLayout;
import android.widget.TextView;

import com.chad.library.adapter.base.BaseQuickAdapter;
import com.ewanghuiju.app.R;
import com.ewanghuiju.app.base.BaseActivity;
import com.ewanghuiju.app.base.contract.shopmail.MailStoreContract;
import com.ewanghuiju.app.model.bean.local.MailShopBean;
import com.ewanghuiju.app.model.bean.local.PintuanTjtgBean;
import com.ewanghuiju.app.model.bean.response.PintuanShopListResponBean;
import com.ewanghuiju.app.presenter.shopmail.MailStorePresenter;
import com.ewanghuiju.app.test.bean.TestBean;
import com.ewanghuiju.app.ui.pintuan.adapter.PintuanShopListAdapter;
import com.ewanghuiju.app.ui.pintuan.adapter.PintuanTjtgAdapter;
import com.ewanghuiju.app.ui.shopmail.adapter.MailStoreAdapter;
import com.ewanghuiju.app.util.ToastUtil;
import com.gyf.immersionbar.ImmersionBar;
import com.makeramen.roundedimageview.RoundedImageView;
import com.scwang.smartrefresh.layout.SmartRefreshLayout;

import java.util.List;

import androidx.recyclerview.widget.GridLayoutManager;
import androidx.recyclerview.widget.LinearLayoutManager;
import androidx.recyclerview.widget.RecyclerView;
import butterknife.BindView;

/**
 * @author sj  qq:751943509
 * @class 店铺页面
 * @time 2020/2/19
 */
public class MailStoreActivity extends BaseActivity<MailStorePresenter> implements MailStoreContract.View {


    @BindView(R.id.toolbar)
    RelativeLayout toolbar;
    @BindView(R.id.refreshLayout)
    SmartRefreshLayout refreshLayout;
    @BindView(R.id.tv_store_name)
    TextView tvStoreName;
    @BindView(R.id.riv_store)
    RoundedImageView rivStore;
    @BindView(R.id.iv_lab)
    ImageView ivLab;
    @BindView(R.id.tv_store_title)
    TextView tvStoreTitle;
    @BindView(R.id.recyclerView)
    RecyclerView recyclerView;

    @Override
    protected void initInject() {
        getActivityComponent().inject(this);
    }

    @Override
    protected int getLayout() {
        return R.layout.activity_mail_store;
    }

    @Override
    protected void initEventAndData() {
        intStoreShopList();
    }

    @Override
    protected void intSmartRefreshLayout() {
    }

    /**
     * 店铺商品列表
     */
    private void intStoreShopList() {
        List<MailShopBean> mailShopBeans = TestBean.getMailShopBeanList(20);
        MailStoreAdapter mailStoreAdapter = new MailStoreAdapter(R.layout.item_pintuan_tjtg);
        mailStoreAdapter.setOnItemClickListener(new BaseQuickAdapter.OnItemClickListener() {
            @Override
            public void onItemClick(BaseQuickAdapter adapter, View view, int position) {
                ToastUtil.show(position + "");
            }
        });
        GridLayoutManager layoutManager = new GridLayoutManager(mContext, 2);
        layoutManager.setSmoothScrollbarEnabled(true);
//        layoutManager.setAutoMeasureEnabled(true);
        recyclerView.setLayoutManager(layoutManager);
        recyclerView.setAdapter(mailStoreAdapter);
        recyclerView.setNestedScrollingEnabled(false);
        recyclerView.setFocusable(false);
        mailStoreAdapter.setNewData(mailShopBeans);
    }

    @Override
    public void showContent(String list) {

    }

    @Override
    public void showMoreContent(String list) {

    }

    @Override
    protected void initImmersionBar() {
        super.initImmersionBar();
        ImmersionBar.with(this).titleBar(toolbar,true)
                .statusBarDarkFont(true)
                .init();
    }
}
